#include <bits/stdc++.h>
// 2025/04/01
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

int s, dp[1001];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    for (int i = 2; i <= s; i++) {
        int cnt = 1;
        for (int j = 2; j * j <= i; j++)
            if (i % j == 0)
                cnt += j + (j * j == i ? 0 : i / j);
        for (int j = s; j >= i; j--)
            dp[j] = max(dp[j], dp[j - i] + cnt);
    }
    cout << dp[s] << endl;
    return 0;
}